<div class="nav">
    <a class="sel" href="{:U('index')}">发送消息</a>
</div>
<div class="add">
    <form method="post" action="" onsubmit="return checkform()" >
        <table class="table_add" cellpadding='8'>
            <tr>
                <td width="100px">发送消息</td>
                <td style="line-height:26px;">
                    <div><label><input type="radio" name="give_type" id="give_type1" value="all" checked="checked" > 所有会员</label></div>
                    <div><label><input type="radio" name="give_type" id="give_type2" value="level" > 按会员等级:</label>
                        <foreach name="level_sel" item="level_name" key="level_id">
                            <label><input type="checkbox" name="level_ids[]" value="{$level_id}" >{$level_name}</label>
                        </foreach>
                    </div>
                    <div><label><input type="radio" name="give_type" id="give_type3" value="single" > 指定会员：</label>
                        <textarea name="member_list" id="member_list" style="width:100%;height:60px; text-align:left;" /></textarea>
                        <label class="msg">输入会员手机号，按英文逗号,分隔</label>
                    </div>
                    
                </td>
            </tr>
            <tr>
                <td>标题</td>
                <td style="line-height:26px;">
                    <input type="text" name="title" id="title" class="input1" style="width:500px" value="" /> 
                </td>
            </tr>
    
            <tr>
                <td>消息内容</td>
                <td style="line-height:26px;">
                    <textarea name="detail" id="detail" style="width:600px; height:200px;"></textarea>
                    
                </td>
            </tr>
            
                 <tr>
                <td>链接</td>
                <td style="line-height:26px;">
                    <input type="text" name="url" id="url" class="input1" style="width:500px" value="" /> 填写则会出现查看详情
                </td>
            </tr
            
            ><tr>
                <td></td>
                <td style="line-height:26px;"><input class="btn1" type="submit" value="提交" /></td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript" >
   
    //表单提交检测
    function checkform() {
       var give_type = $("input[name='give_type']:checked").val();
       var title = $.trim($("#title").val());
       var level_ids = $("input[name='level_ids[]']:checked").val();
       var member_list = $.trim($("#member_list").val());
       if(give_type == "level") {
           if(level_ids == undefined) {
               alert("请至少选择一个会员等级！");
               return false;
           }
       } else if (give_type == "single") {
           if(member_list == "") {
               alert("请至少填写一个会员！");
               $("#member_list").focus();
               return false;
           }
       } else if (title == "") {
           alert("请填写标题！");
           $("#title").focus();
           return false;
       }
    }
</script>
